package com.example;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class IndexController {

    @GetMapping("")
    public String index(HttpServletRequest request) {
        request.setAttribute("name", "公众号：java思维导图");
        return "index";
    }

    @PostMapping("/submit")
    public String submit(HttpServletRequest request) {
        String name = request.getParameter("name");
        System.out.println("name---------->" + name);

        // 假装只有名字为求关注才能通过
        if(!name.equals("求关注")) {
            request.setAttribute("name", name);
        }

        return "index";
    }


//    HTMLFilter htmlFilter = new HTMLFilter();
//    name = htmlFilter.filter(name);
//        System.out.println("name---------->" + name);


}
